package chapter2;

import static org.junit.Assert.*;

import org.junit.Test;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.openqa.selenium.interactions.Actions;
import org.openqa.selenium.support.FindBy;
import org.openqa.selenium.support.PageFactory;
import org.testng.Assert;

public class TestDragAndDrop {
	@FindBy(id = "draggable") WebElement drag;
	@FindBy(id = "droppable") WebElement drop;

	@Test
	public void test() {
		WebDriver driver = new FirefoxDriver();
		driver.get("http://dl.dropbox.com/u/55228056/DragDropDemo.html");
		/*WebElement drag = driver.findElement(By.id("draggable"));
		WebElement drop = driver.findElement(By.id("droppable"));*/
		TestDragAndDrop testDragAndDrop = PageFactory.initElements(driver, TestDragAndDrop.class);
		Actions builder = new Actions(driver);
		builder.dragAndDrop(testDragAndDrop.drag,testDragAndDrop.drop).build().perform();
		Assert.assertEquals("Dropped!", testDragAndDrop.drop.getText());
		driver.close();
	}

}
